<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <title>@Model.DBName 数据库设计文档</title>
    <style type="text/css">
        body {
            padding-bottom: 50px
        }

        body, td {
            font-family: verdana, fantasy;
            font-size: 12px;
            line-height: 150%
        }

        table {
            width: 100%;
            background-color: #ccc;
            margin: 5px 0
        }

        td {
            background-color: #fff;
            padding: 3px 3px 3px 10px
        }

        thead td {
            text-align: center;
            font-weight: 700;
            background-color: #eee;
            padding: 3px;
        }
		
		.text-center{
			text-align:center;
            padding: 3px;			
		}

        a:active, a:link, a:visited {
            color: #015fb6;
            text-decoration: none
        }

        a:hover {
            color: #e33e06
        }
    </style>
</head>
<body style="text-align:center">
    <div style="width: 850px; margin: 20px auto; text-align: left">
        <a name="index"></a>
        <h2 style="text-align: center; line-height: 50px">@Model.DocTitle</h2>
        <div>
            <b>数据库名：@Model.DBName</b><br>
            <b>文档版本：v1.0.1</b><br>
            <b>文档描述：无</b><br>
        </div>
        <table cellspacing="1">
            <thead>
                <tr>
                    <td style="width: 40px">序号</td>
                    <td>表名</td>
                    <td>说明</td>
                </tr>
            </thead>
            @{
                int i = 1;
                foreach (var item in Model.Tables)
                {
                    <tr>
                        <td class="text-center">@i</td>
                        <td><a href="#@item.TableName">@item.TableName</a></td>
                        <td>@item.Comment</td>
                    </tr>
                    {
                        i++;
                    }
                }
            }
        </table>
    @foreach (var item in Model.Tables)
    {
        <a name="@item.TableName"></a>
        <div style="margin-top: 30px">
            <a href="#index" style="float: right; margin-top: 6px">返回目录</a>
            <b>表名：@item.TableName</b>
        </div>
        <div>说明：@item.Comment</div>
        <div>数据列：</div>
        <table cellspacing="1">
            <thead>
                <tr>
                    <td style="width: 40px">序号</td>
                    <td>列名</td>
                    <td>数据类型</td>
                    <td>长度</td>
                    <td>主键</td>
                    @if (!item.DBType.StartsWith("Oracle"))
                    {
                        <td>自增</td>
                    }
                    <td>允许空值</td>
                    <td>默认值</td>
                    <td>说明</td>
                </tr>
            </thead>
            @{
                var index = 1;
                foreach (var col in item.Columns)
                {
                    <tr>
                        <td class="text-center">@index</td>
                        <td>@col.ColumnName</td>
                        <td class="text-center">@col.ColumnTypeName</td>
                        <td class="text-center">@col.Length</td>
                        <td class="text-center">@col.IsPK</td>
                        @if (!item.DBType.StartsWith("Oracle"))
                        {
                            <td class="text-center">@col.IsIdentity</td>
                        }
                        <td class="text-center">@col.CanNull</td>
                        <td class="text-center">@col.DefaultVal</td>
                        <td>@col.Comment</td>
                    </tr>
                    {
                        index++;
                    }
                }
            }
        </table>
    }
    </div>
</body>
</html>